<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>校园活动面板</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            display: flex;
            flex-direction: column;
            align-items: center;
            padding: 20px;
            background-color: #f0f0f0;
        }
        h1 {
            font-size: 24px;
            margin-bottom: 20px;
        }
        h2 {
            font-size: 18px;
            margin-bottom: 10px;
        }
        form {
            margin-bottom: 20px;
            display: flex;
            flex-direction: column;
            align-items: flex-start;
        }
        input {
            margin: 5px 0;
            padding: 5px;
            width: 200px;
        }
        button {
            padding: 5px 10px;
            margin-top: 10px;
        }
        .activity {
            background: #fff;
            padding: 10px;
            margin: 5px;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
            width: 350px;
        }
    </style>
</head>
<body>
    <div id="app">
        <h1>添加校园活动</h1>
        <form @submit.prevent="addActivity">
            <input type="text" v-model="newName" placeholder="活动名称" required>
            <input type="text" v-model="newTime" placeholder="活动时间" required>
            <input type="text" v-model="newLocation" placeholder="活动地点" required>
            <button type="submit">添加活动</button>
        </form>
        <h2>活动列表</h2>
        <div v-for="activity in activities" :key="activity.id" class="activity">
            <h3>{{ activity.name }}</h3>
            <p>时间：{{ activity.time }}</p>
            <p>地点：{{ activity.location }}</p>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                newName: '',
                newTime: '',
                newLocation: '',
                activities: [],
                nextId: 1  // 用于生成活动的唯一ID
            },
            methods: {
                addActivity() {
                    if (this.newName && this.newTime && this.newLocation) {
                        const newActivity = {
                            id: this.nextId++,
                            name: this.newName,
                            time: this.newTime,
                            location: this.newLocation
                        };
                        this.activities.push(newActivity);
                        this.newName = '';
                        this.newTime = '';
                        this.newLocation = '';
                    } else {
                        alert('请填写所有字段');
                    }
                }
            }
        });
    </script>
</body>
</html>